cmake_minimum_required(VERSION 3.6)
project(neovymcpp)

set(CMAKE_CXX_STANDARD 17)

add_subdirectory(deps/base/dpp)
add_subdirectory(deps/rest/beast)
add_subdirectory(deps/ws/simpleweb)
add_subdirectory(deps/util/overload)
add_subdirectory(deps/util/responder)
add_subdirectory(deps/rest/ratelimit)
add_subdirectory(deps/util/consts)
add_subdirectory(deps/end/points)
add_subdirectory(deps/util/interaction)

set(SOURCE_FILES src/source.cc src/extern.cc)
add_executable(${PROJECT_NAME} ${SOURCE_FILES})


set(THREADS_PREFER_PTHREAD_FLAG ON)

find_package(Boost REQUIRED system date_time)
find_package(Threads REQUIRED)
find_package(OpenSSL REQUIRED)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic")

TARGET_LINK_LIBRARIES(
        ${PROJECT_NAME}
        ${Boost_LIBRARIES}
        Threads::Threads
        ${OPENSSL_LIBRARIES}
        discordpp
        discordpp-rest-beast
        discordpp-websocket-simpleweb
        discordpp-plugin-overload
        discordpp-plugin-responder
        discordpp-plugin-ratelimit
        discordpp-plugin-constructs
        discordpp-plugin-endpoints
        discordpp-plugin-interactionhandler
)

function(SYNC_FILE FILE)
    if (EXISTS ${CMAKE_SOURCE_DIR}/${FILE})
        configure_file(${FILE} ${CMAKE_CURRENT_BINARY_DIR} COPYONLY)
    elseif (EXISTS ${CMAKE_CURRENT_BINARY_DIR}/${FILE})
        file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/${FILE})
    endif ()
endfunction(SYNC_FILE)

SYNC_FILE(token.dat)